<%@ page contentType="text/html;charset=UTF-8" trimDirectiveWhitespaces="true"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<c:set var="extLibs" value="validate"/>
<sys:header title="群组表管理 - ${msgNoteGroup.isNewRecord ? '新增' : '编辑'}群组表" extLibs="${extLibs}"/>
<div class="portlet box ${boxStyleColor} autoHeight">
	<div class="portlet-title">
		<div class="caption"><i class="fa fa-coffee"></i>${msgNoteGroup.isNewRecord ? '新增' : '编辑'}群组表</div>
		<%-- <div class="actions">
			<shiro:hasPermission name="msg:msgNoteGroup:edit">
				<a href="#" class="btn btn-default btn-sm" onclick="$('#btnSubmit').click();return false;"><i class="fa fa-check"></i> 保 存</a>
			</shiro:hasPermission>
			<a href="#" class="btn btn-default btn-sm" onclick="$('#btnCancel').click();return false;"><i class="fa fa-reply-all"></i> 关 闭</a>
		</div> --%>
	</div>
	<div class="portlet-body form">
		<form:form id="inputForm" modelAttribute="msgNoteGroup" action="${ctx}/msg/msgNoteGroup/save" method="post" class="form-horizontal">
			<div class="form-body">
				<h4 class="form-section">基本信息</h4>
				<form:hidden path="groupId"/>
				<form:hidden path="mobiles"/>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								群组名：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<form:input path="groupName" htmlEscape="false" maxlength="100" class="form-control"/>
							</div>
						</div>
					</div>

				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								群成员：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<sys:listselect id="member" name="memberCodes" value="${msgNoteGroup.memberCodes}" labelName="memberNames" labelValue="${msgNoteGroup.memberNames}"
												title="会员" url="${ctx}/mdm/member/memberSelect" multiple="true"  cssClass="form-control required" />
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								群组介绍：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<form:textarea path="description" htmlEscape="false" rows="4" maxlength="255" class="form-control"/>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="form-actions fluid">
				<div class="row">
					<div class="col-xs-12">
						<div class="col-sm-offset-2 col-sm-10">
							<shiro:hasPermission name="msg:msgNoteGroup:edit">
								<button id="btnSubmit" type="submit" class="btn btn-primary"><i class="fa fa-check"></i> 保 存</button>&nbsp;
							</shiro:hasPermission>
							<button id="btnCancel" type="button" class="btn default" onclick="closeCurrentTabPage('${param.parentTabPageId}')"><i class="fa fa-reply-all"></i> 关 闭</button>
						</div>
					</div>
				</div>
			</div>
		</form:form>
	</div>
</div>
<sys:footer extLibs="${extLibs}"/>
<script type="text/javascript">
	$("#inputForm").validate({
		submitHandler: function(form){
			ajaxSubmitForm($(form), function(data){
				showMessage(data.message);
				if(data.result == Global.TRUE){
					closeCurrentTabPage('${param.parentTabPageId}', function(contents, contentWindow){
						contentWindow.page();
					});
				}
			}, "json");
	    }
	});

	//会员选择回调
	function memberCallbackForMap(dataMap, v, h, f){
		var codes = [], names = [],mobiles=[];
		$.each(dataMap, function(key, value){
			codes.push(value.memberCode);
			names.push(value.memberName);
			mobiles.push(value.phone);

		});
		$('#memberCode').val(codes.join(','));
		$('#memberName').val(names.join(','));
		$('#mobiles').val(mobiles.join(','));
	}



	// 人员选择初始默认
	function memberBeforeForMap(selectData){
		var codes = $('#memberCode').val();
		var names = $('#memberName').val();
		var mobiles = $('#mobiles').val();
		var codesArr = new Array();
		var namesArr = new Array();
		var mobilesArr = new Array();
		if(codes != null && codes !="" && names != null && names != ""){
			codesArr = codes.split(",");
			namesArr = names.split(",");
			var jsons = {}, str = "";
			for(var i=0; i<codesArr.length; i++) {

				str = '{"memberCode":"'+codesArr[i]+'","memberName":"'+namesArr[i]+'"}';
				jsons[codesArr[i]] = JSON.parse(str);
			}
			if(codesArr.length > 0){
				selectData = JSON.stringify(jsons);
				selectData = selectData.replace(new RegExp("\"","g"),"\'");
			}
		}
		return selectData;
	}
</script>